package com.best;

import com.best.config.RabbitmqConfig;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * @author Jiang Akang
 * employeeId: BG435424
 * @date 2020/11/20
 **/
@SpringBootTest
@RunWith(SpringRunner.class)
public class Producer {

    @Autowired
    RabbitTemplate rabbitTemplate;

    //使用rabbitTemplate发送消息
    @Test
    public void testSendEmail() {
        //匹配ROUTINGKEY_EMAIL路由键，发送消息到ROUTINGKEY_EMAIL队列
        String message = "send email message to ROUTINGKEY_EMAIL";
         rabbitTemplate.convertAndSend(RabbitmqConfig.EXCHANGE_TOPICS_INFORM, "inform.email", message);
    }

    //使用rabbitTemplate发送消息
    @Test
    public void testSendEmail1() {
        //匹配ROUTINGKEY_SMS路由键，发送消息到ROUTINGKEY_SMS队列
        String message = "send email message to ROUTINGKEY_SMS";
         rabbitTemplate.convertAndSend(RabbitmqConfig.EXCHANGE_TOPICS_INFORM, "inform.sms", message);
    }


}
